package cn.yudao.basic.listener;

import cn.yudao.basic.service.IPermissionScanService;
import cn.yudao.system.service.IPermissionService;
import cn.yudao.system.service.impl.PermissionServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
@Slf4j
public class PermissionScanInitIistener implements ServletContextListener {
    @Autowired
    private IPermissionScanService permissionScanService;

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        log.info("Permission....start");
        new Thread(()->{
            permissionScanService.scan();
        }).start();
        log.info("Permission....stop");
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
    }
}
